﻿-- Define the relationship between SecurityRoleAccess and SecurityRole
ALTER TABLE [dbo].[SecurityRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_SecurityRoleAccess_SecurityRole] FOREIGN KEY([Role])
REFERENCES [dbo].[SecurityRole] ([RoleId])
ON DELETE NO ACTION
GO
-- Define the relationship between SecurityRoleAccess and SecurityRole
ALTER TABLE [dbo].[SecurityRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_SecurityRoleAccess_RoleAccessing] FOREIGN KEY([SecurityRole])
REFERENCES [dbo].[SecurityRole] ([RoleId])
ON DELETE NO ACTION
GO
-- Define the relationship between SecurityRoleAccess and Person
ALTER TABLE [dbo].[SecurityRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_SecurityRoleAccess_CreatedByPerson] FOREIGN KEY([CreatedBy])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO
-- Define the relationship between SecurityRoleAccess and Person
ALTER TABLE [dbo].[SecurityRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_SecurityRoleAccess_LastChangedBy] FOREIGN KEY([LastChangedBy])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO
-- Define the relationship between SecurityRoleAccess and Person
ALTER TABLE [dbo].[SecurityRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_SecurityRoleAccess_Person] FOREIGN KEY([Person])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO